<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>录入页</title>
<%@ include file="/common.jsp"%>
<meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
</head>


<body>
	<div style="margin:10px;">
	本实例假设：<br/>
	学生实体：多个学生对应一个老师，多个学生对应一个教室(many-to-one)<br/>
	老师实体：一个老师对应多个学生(one-to-many)，一个老师对应一个教室(one-to-one)<br/>
	教室实体：一个教室对应多个学生(@OneToMany)<br/>
	</div>
	<form name="classRoomform" action="hb.do?method=addclassroom" method="post">
		<table cellspacing="1" class="tb">
			<tr>
				<th colspan="5">教室管理</th>
			</tr>
			
			<c:forEach items="${roomlst}" var="room">
			<tr>
				<th>教室ID：</th>
				<td>${room.roomId}</td>
				<th>教室名：</th>
				<td>${room.roomName}</td>
				<td><a href="hb.do?method=delete&type=c&id=${room.roomId}">删除</a></td>
			</tr>
			</c:forEach>
			
			<tr>
				<th>教室ID：</th>
				<td><input type="text" name="roomId" /></td>
				<th>教室名：</th>
				<td><input type="text" name="roomName" /></td>
				<td><input type="submit" value="保存" /></td>
			</tr>
		</table>
	</form>

	<form name="teacherform" action="hb.do?method=addteacher" method="post">
		<table cellspacing="1" class="tb">
			<tr>
				<th colspan="7">教师管理</th>
			</tr>
			
			<c:forEach  items="${teacherlst}" var="teacher">
			<tr>
				<th>教室(ID+名)：</th>
				<td>${teacher.classRoom.roomId}&nbsp;${teacher.classRoom.roomName}</td>
				<th>教师ID：</th>
				<td>${teacher.tcid}</td>
				<th>教师名：</th>
				<td>${teacher.tcName}</td>
				<td><a href="hb.do?method=delete&type=t&id=${teacher.tcid}">删除</a></td>
			</tr>
			</c:forEach>
			
			<tr>
				<th>教室ID：</th>
				<td><input type="text" name="classRoom.roomId" /></td>
				<th>教师ID：</th>
				<td><input type="text" name="tcid" /></td>
				<th>教师名：</th>
				<td><input type="text" name="tcName" /></td>
				<td><input type="submit" value="保存" /></td>
			</tr>
		</table>
	</form>

	<form name="studentform" action="hb.do?method=addstudent" method="post">
		<table cellspacing="1" class="tb">
			<tr>
				<th colspan="9">学生管理</th>
			</tr>
			
			<c:forEach items="${studentlst}" var="student">
			<tr>
				<th>教室ID：</th>
				<td>${student.classRoom.roomId}&nbsp;${student.classRoom.roomName}</td>
				<th>教师ID：</th>
				<td>${student.teacher.tcid}&nbsp;${student.teacher.tcName}</td>
				<th>学生ID：</th>
				<td>${student.stuid}</td>
				<th>学生名：</th>
				<td>${student.stuName}</td>
				<td><a href="hb.do?method=delete&type=s&id=${student.stuid}">删除</a></td>
			</tr>
			</c:forEach>
			
			<tr>
				<th>教室ID：</th>
				<td><input type="text" name="classRoom.roomId" /></td>
				<th>教师ID：</th>
				<td><input type="text" name="teacher.tcid" /></td>
				<th>学生ID：</th>
				<td><input type="text" name="stuid" /></td>
				<th>学生名：</th>
				<td><input type="text" name="stuName" /></td>
				<td><input type="submit" value="提交" /></td>
			</tr>
		</table>
	</form>

	<form name="studentsform" action="hb.do?method=addstudents" method="post">
		<input type="hidden" name="id" value="${userid}"/>
			<table cellspacing="1" class="tb">
				<tr>
					<th colspan="4">添加多个学生</th>
				</tr>
				<tr>
					<th>课室：</th>
					<td colspan="3"><input type="text" name="roomId" /></td>
				</tr>
				<tr>
					<th>学生ID：</th>
					<td><input type="text" name="students[0].stuid" value="sa" /></td>
					<th>学生名：</th>
					<td><input type="text" name="students[0].stuName"  value="小王"/></td>
				</tr>
				<tr>
					<th>学生ID：</th>
					<td><input type="text" name="students[1].stuid" value="sb" /></td>
					<th>学生名：</th>
					<td><input type="text" name="students[1].stuName" value="小黄" /></td>
				</tr>
				<tr>
					<td colspan="4"><input type="submit" value="提交" /></td>
				</tr>
			</table>
	</form>

</body>
</html>
